<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<title>考前猜题卷</title>
<meta name="Keywords" content="">
<meta name="Description" content="">
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link rel="stylesheet" type="text/css" href="https://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/css/zhaomu.css"/>
<link rel="stylesheet" type="text/css" href="https://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/css/questionnaire.css"/>
<script type="text/javascript" src="https://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/js/layer_mobile/layer.js"></script>
<link rel="stylesheet" type="text/css" href="https://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/css/layer.css" />
<script src="https://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/js/jquery.1.9.1.js"></script>
<script type="text/javascript" src="https://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/js/rem.js"></script>
<script type="text/javascript" src="https://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/js/address_select/mobileSelect.js"></script>
<link rel="stylesheet" type="text/css" href="https://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/js/address_select/mobileSelect.css" />
<style>
	.radio-labels:before{
		margin-left: 15px;
	}
	.huoqu{
		border: none;
		outline: none;
		appearance: none;
		-wibkit-appearance:none;
	}
</style>
</head>
<body class="body_tj">
<div id="tbh5v0">
<div id="wenjuanqqwe">
<img style="width: 100%;" src="https://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/images/question_top3.jpg"/>
<ul class="question">
	{foreach name="$info" item="vo"}
	<li>
		<p>{$key+1}. {$vo->name} {if $vo->must_fil == 1}<span style="color: #ff0000;">*</span>{/if}</p>
		<input type="hidden" id="wenjuan{$key}" value="{$vo->must_fil}" />
		<input type="hidden" id="wenjuantype{$key}" value="{$vo->type}" />
		{if $vo.type == 1}
		{foreach name="$vo->Datas" key="k" item="v" }
		<p>
			<input  type="radio" name="wenjuan{$key}" id="a{$key}{$k}" value="{$vo->id}-{$v->name}-{$v->answer}" />
			
			<label class="radio-label" for="a{$key}{$k}"><span>{$v->name}.{$v->answer}</span></label>
		</p>
		{/foreach}
		{elseif $vo.type == 2}
				{foreach name="$vo->Datas" key="k" item="v" }
		<p>
			<input type="checkbox" name="wenjuan{$key}" id="a{$key}{$k}" value="{$vo->id}-{$v->name}-{$v->answer}" />
			<label class="checkbox-label" for="a{$key}{$k}"><span>{$v->name}.{$v->answer}</span></label>
		</p>
		{/foreach}
		{/if}
	</li>
	{/foreach}

</ul>
<div class="question_mid">
	<p class="mid_top">感谢您的答题！祝孩子考出最好的自己，高考成功！</p>
	<div>
		<p class="mid_mid">
		<p class="ktkj">提交问卷后</p>
		<p class="ktkj">查看《考前猜题卷》电子版样张</p>
		<span class="question_submit">点击领取电子版</span>
		</p>
	</div>
	<!--<p class="mid_bottom">* 语文为不公开领取，只公布电子版样张供家长参考</p>-->
</div>
<!-- <div class="question_mid">
	<img class="mid_img" src="http://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/images/mid_top.jpg"/>
	<img class="mid_img question_submit" src="http://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/images/mid_mid.jpg"/>
	<p class="mid_bottom">* 语文为不公开领取，只公布电子版样张供家长参考</p>
</div> -->

</div>

<script>
var count = {:count($info)};
var jsonData={};
$(function(){
	$('.question_submit').click(function(){
		for (var i = 0; i < count; i++) {
			var type= $("#wenjuantype"+i).val();
			console.log(type);
			if(type == 1){
				var wenjuan = $("input[name='wenjuan"+i+"']:checked").val();
			}else if(type == 2){
				var wenjuan = "";
				$("input[name='wenjuan"+i+"']:checked").each(function(){
					wenjuan += $(this).val() + "||"; 
				});
				if(wenjuan.length > 0){
					wenjuan = wenjuan.substring(0, wenjuan.length - 2); //把最后一个逗号去掉
				}
				console.log(wenjuan);
			} 
			var must_fil= $("#wenjuan"+i).val();
			
			if(must_fil == 1){
				if(wenjuan == ""||wenjuan == null){
					layer.open({
						content: '请作答',
						skin: 'msg',
						time: 2 //2秒后自动关闭
					});
					return false;
				}
			}
			jsonData['wenjuan'+i] = wenjuan;
		}
		console.log(jsonData);
		$.ajax({
			type: 'post',
			url:"/index/ques/volumepost/ids/{$row->id}" , 
			data:jsonData,
			success: function(data){
				console.log(data);
				if(data.code == 0){
		            layer.open({
		              content: data.msg,//您未认真听讲或未认真答题，请重新答题
		              skin: 'msg',
		              time: 2,
		            });
		            return false;
		         }else{
		         	layer.open({
		              content: data.msg,//您未认真听讲或未认真答题，请重新答题
		              skin: 'msg',
		              time: 2,
		            });
		         	$('.addressmone').show();
		         	$('.question_mid').show();
		         	$('#wenjuanqqwe').hide();
		         	// $('.question_mid a').css('color','#001f6e');
		         	// $('.question_mid a').attr('href','http://tmall.fc62.com/yz_list.html');
		         	$('body').animate({ scrollTop: 0 }, 0);
		         }
			}
		});
	});
});
</script>
<div class="addressmone">

<div class="question_mid">
	<img class="mid_img" src="http://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/images/question_mid1.jpg"/>
</div>
	<ul>
	   <!--<li>-->
		 <!--<h1 class="form_top">如需纸质版,请填写领取寄送地址 </h1>-->
		 <!--<p style="color: #ff0000;">* 免收快递费</p>-->
	   <!--</li>-->
	   <li>
		 <p class="form_con">联系人 <span style="color: #ff0000;">*</span></p>
		 <input type="text" name="consignee" value="" id="name" >
		 <img src="http://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/images/form_03.jpg"/>
	   </li>
	   <li>
		 <p class="form_con">联系电话 <span style="color: #ff0000;">*</span></p>
		 <input type="number" pattern="[0-9]*" name="" id="tel" value="" />
		 <img style="bottom: 0.9rem;" src="http://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/images/form_06.jpg"/>
		 <input style="width: 59%;" type="number" name="" id="code" pattern="[0-9]*" value="" />
		 <input type="button" class="huoqu" value="获取验证码">
		 <img src="http://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/images/form_01.png"/>
		</li>
		<li>

			<p class="form_con">版本 <span style="color: #ff0000;">*</span></p>
			<div style="margin-top: 5px;">
				<input type="radio" name="type" id="radio1" value="全国版" />
				<label class="radio-labels" for="radio1"><span>全国版</span></label>
				<input type="radio" name="type" id="radio2" value="北京版" />
				<label class="radio-labels" for="radio2"><span>北京版</span></label>
				<input type="radio" name="type" id="radio3" value="江苏版" />
				<label class="radio-labels" for="radio3"><span>江苏版</span></label>
			</div>
			<div style="margin-top: 5px;">
				<input type="radio" name="type" id="radio4" value="浙江版" />
				<label class="radio-labels" for="radio4"><span>浙江版</span></label>
				<input type="radio" name="type" id="radio5" value="新高考版" />
				<label class="radio-labels" for="radio5"><span>新高考版</span></label>
			</div>
		</li>
		<li style="position: relative;">
		 <p class="form_con">所在地区 <span style="color: #ff0000;">*</span></p>
		 <div id="trigger4" class="trigger4" style="text-indent:0.5em;display: inline-block;border: 1px solid #ccc;width: 100%;height: 35px;line-height: 35px;border-radius: 5px;overflow: hidden;">
			<span style="color: #666;">请选择</span>
		 </div>
		 <img style="position: absolute;bottom: 0.3rem;left: 92%;width: 0.26rem;height: 0.13rem;" src="http://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/images/tj.png"/>
		 <input type="hidden" name="" id="sheng" value="" />
		 <input type="hidden" name="" id="shi" value="" />
		 <input type="hidden" name="" id="xian" value="" />
	  </li>

	  <!--<li>-->
	  	<!--<p class="form_con">详细地址 <span style="color: #ff0000;">*</span></p>-->
    		 <!--<textarea name="address" id="address"></textarea>-->
	   <!--</li>-->

    	</ul>
            
     <div class="dotm_btn">
     	<input type="submit" value="提 交" class="dotm_btn1">
     </div>

</div>
</div>

<script>
	$(function(){
		var mobileSelect4 = new MobileSelect({
		    trigger: '#trigger4',
		    title: '地区选择',
		    wheels: [{data:[
		    					{
	                            id:'1',
	                            value:'',
	                            childs:[
	                                {id:'A1',value:''},
	                            ]
	                        }
		    			]}],
			 transitionEnd:function(indexArr, data){
			        
			 },
			 callback:function(indexArr, data){
			 	console.log(data);
			    $('#sheng').val(data[0].id);
			    $('#shi').val(data[1].id);
			    $('#xian').val(data[2].id);
			 }  
		});
		 $.ajax({
	        type: "get",
	        url: "/api/ajax/area",
	        dataType: "json",
	        success: function(res){
	            mobileSelect4.updateWheels(res.data);
	        }
	  });
	  $('.huoqu').click(function() {
      var tel = $('#tel').val();
      if(!(/^1[3456789]\d{9}$/.test(tel))) {
        layer.open({
          content: '请输入正确的手机号码',
          skin: 'msg',
          time: 2 //2秒后自动关闭
        });
        return false;
      }
      $.ajax({
        type: 'post',
        url:"/api/sms/send" ,
        data:{mobile:tel,event:'examiation'},
        success: function(data){
          console.log(data);
          if(data.code != 1){
            layer.open({
              content:data.msg ,
              skin: 'msg',
              time: 2 //2秒后自动关闭
            });
            return false
          }else{
            var count = 120;
            const countDown = setInterval(() => {
              if (count === 0) {
                $('.huoqu').val('重新发送').removeAttr('disabled');
                $('.huoqu').css({
                  background: '#f3494c',
                  color: '#fff',
                });
                clearInterval(countDown);
              } else {

                $('.huoqu').css({
                  background: '#eee',
                  color: '#333',
                });
                $('.huoqu').val(count + '秒后可重新获取');
                  $('.huoqu').attr('disabled', true);
              }
              count--;
            }, 1000);
          }
        }
      });
    });
	  	$('.dotm_btn1').click(function(){
	  		var sheng = $('#sheng').val();
			var shi = $('#shi').val();
			var xian = $('#xian').val();
			var code = $('#code').val();
			var name = $('#name').val();
			var tel = $('#tel').val();
			// var address = $('#address').val();
            var type = $("input[name='type']:checked").val();

			if(name == ""||name == null){
				layer.open({
					content: '请填写姓名',
					skin: 'msg',
					time: 2 //2秒后自动关闭
				});
				return false;
			}
			
			if(!(/^1[3456789]\d{9}$/.test(tel))) {
				layer.open({
					content: '请输入正确的手机号码',
					skin: 'msg',
					time: 2 //2秒后自动关闭
				});
				return false;
			}
			  if(code == ""||code == null){
		        layer.open({
		          content: '请填写验证码',
		          skin: 'msg',
		          time: 2 //2秒后自动关闭
		        });
		        return false;
		      }
      		if(sheng == ""||sheng == null){
				layer.open({
					content: '请选择所在省份',
					skin: 'msg',
					time: 2 //2秒后自动关闭
				});
				return false;
			}
			if(shi == ""||shi == null){
				layer.open({
					content: '请选择所在城市',
					skin: 'msg',
					time: 2 //2秒后自动关闭
				});
				return false;
			}
			// if(address == ""||address == null){
			// 	layer.open({
			// 		content: '请填写详细地址',
			// 		skin: 'msg',
			// 		time: 2 //2秒后自动关闭
			// 	});
			// 	return false;
			// }
            if(type == ""|| type == null){
                layer.open({
                    content: '请填写领取版本',
                    skin: 'msg',
                    time: 2 //2秒后自动关闭
                });
                return false;
            }
			 var index = layer.open({type: 2});
			     //验证验证码
		      $.ajax({
		        type: 'post',
		        url:"/api/sms/check" ,
		        data:{mobile:tel,captcha:code,event:'examiation'},
		        success: function(data){
		          if(data.code == 0){
		          	layer.close(index);
		            layer.open({
		              content: data.msg,
		              skin: 'msg',
		              time: 2,
		            });
		            return false;
		          }else{
		          	  //添加禁止标签
            	$('.dotm_btn1').attr("disabled","disabled");
					//提交表单
					$.ajax({
						type: 'post',
						url:"/index/ques/examiation" ,
						data:{shen:sheng,shi:shi,xian:xian,name:name,phone:tel,type:type},
						success: function(data){
							console.log(data);
							if(data.code == 0){
								layer.close(index);
								$('.dotm_btn1').attr("disabled","");
					            layer.open({
					              content: data.msg,
					              skin: 'msg',
					              time: 2,
					            });
					            return false;
					         }else{
					         	layer.close(index);
					         	if(type=="全国版"){
                                    window.location.href="http://uploadfile.fc62.com/caiti/%E7%8C%9C%E9%A2%98%E5%8D%B7-%E5%85%A8%E5%9B%BD-%E5%85%A8.pdf";
								}else if(type=="北京版"){
                                    window.location.href="http://uploadfile.fc62.com/caiti/%E7%8C%9C%E9%A2%98%E5%8D%B7-%E5%8C%97%E4%BA%AC-%E5%85%A8.pdf";
								}else if(type=="江苏版"){
                                    window.location.href="http://uploadfile.fc62.com/caiti/%E7%8C%9C%E9%A2%98%E5%8D%B7-%E6%B1%9F%E8%8B%8F-%E5%85%A8.pdf";
                                }else if(type=="浙江版"){
                                    window.location.href="http://uploadfile.fc62.com/caiti/%E7%8C%9C%E9%A2%98%E5%8D%B7-%E6%B5%99%E6%B1%9F-%E5%85%A8.pdf";
                                }else if(type=="新高考版"){
                                    window.location.href="http://uploadfile.fc62.com/caiti/%E7%8C%9C%E9%A2%98%E5%8D%B7-%E6%96%B0%E9%AB%98%E8%80%83-%E5%85%A8.pdf";
                                }

                            }

						}
					});
				}

		        }
		      });
		});
					
	});
</script>
</body>

</html>